/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.financial.service.arrivalreminder;

import com.jeesite.common.entity.Page;
import com.jeesite.common.service.CrudService;
import com.jeesite.modules.custom.service.CodeRuleService;
import com.jeesite.modules.file.utils.FileUploadUtils;
import com.jeesite.modules.financial.dao.arrivalreminder.ArrivalReminderDao;
import com.jeesite.modules.financial.entity.arrivalreminder.ArrivalReminder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 到单提醒Service
 * @author LV
 * @version 2021-03-04
 */
@Service
@Transactional(readOnly=true)
public class ArrivalReminderService extends CrudService<ArrivalReminderDao, ArrivalReminder> {

    @Autowired
    private CodeRuleService codeRuleService;

	/**
	 * 获取单条数据
	 * @param arrivalReminder
	 * @return
	 */
	@Override
	public ArrivalReminder get(ArrivalReminder arrivalReminder) {
		return super.get(arrivalReminder);
	}
	
	/**
	 * 查询分页数据
	 * @param arrivalReminder 查询条件
	 * @param arrivalReminder.page 分页对象
	 * @return
	 */
	@Override
	public Page<ArrivalReminder> findPage(ArrivalReminder arrivalReminder) {
		return super.findPage(arrivalReminder);
	}
	
	/**
	 * 保存数据（插入或更新）
	 * @param arrivalReminder
	 */
	@Override
	@Transactional(readOnly=false)
	public void save(ArrivalReminder arrivalReminder) {
        if (arrivalReminder.getIsNewRecord()) {
            arrivalReminder.setArrivalReminderCode(codeRuleService.getCode("arrivalReminder"));
        }
		super.save(arrivalReminder);
        if (arrivalReminder.getIsNewRecord()) {
            codeRuleService.updateCurrentNumber("arrivalReminder");
        }
		// 保存上传图片
		FileUploadUtils.saveFileUpload(arrivalReminder.getId(), "arrivalReminder_image");
		// 保存上传附件
		FileUploadUtils.saveFileUpload(arrivalReminder.getId(), "arrivalReminder_file");
	}
	
	/**
	 * 更新状态
	 * @param arrivalReminder
	 */
	@Override
	@Transactional(readOnly=false)
	public void updateStatus(ArrivalReminder arrivalReminder) {
		super.updateStatus(arrivalReminder);
	}
	
	/**
	 * 删除数据
	 * @param arrivalReminder
	 */
	@Override
	@Transactional(readOnly=false)
	public void delete(ArrivalReminder arrivalReminder) {
		super.delete(arrivalReminder);
	}
	
}